package com.digitaldreamers.framework.network;

import com.digitaldreamers.framework.BaseConstants;

import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiManager;

public class NetworkUtilities {
	public static String retrieveMacAddress(final Activity pActivity) {
		WifiManager wifiManager = (WifiManager)pActivity.getSystemService(Context.WIFI_SERVICE);
	    String macAddress = wifiManager.getConnectionInfo().getMacAddress();
	    if(macAddress == null || "".equals(macAddress)) {
	    	wifiManager.setWifiEnabled(true);
	    	for(int i = 0; i < BaseConstants.MAX_GETTING_MAC_ADDRESS_ATTEMPTS; i++) {
	    		macAddress = wifiManager.getConnectionInfo().getMacAddress();
	    		if(macAddress != null && !macAddress.equals("")) {
	    			break;
	    		}
	    	}
	    	wifiManager.setWifiEnabled(false);
	    }
	    return macAddress;
	}
}
